package com.kingdee.pda.ui.query_replenish_order;

import android.os.Bundle;
import android.view.View;
import android.widget.ListView;
import android.widget.TextView;

import com.kingdee.pda.R;
import com.kingdee.pda.adapter.ReplenishSkuAssignmentDetailAdapter;
import com.kingdee.pda.adapter.ReplenishSkuGroundingDetailAdapter;
import com.kingdee.pda.entity.ReplenishOrderDetailBean.DataBean.AllotsBean;
import com.kingdee.pda.entity.ReplenishOrderDetailBean.DataBean.ItemsBean;
import com.kingdee.pda.entity.ReplenishOrderDetailBean.DataBean.PutawaysBean;
import com.kingdee.pda.ui.activity.BaseActivity;
import com.kingdee.pda.util.FastClickUtil;
import com.kingdee.pda.util.ToastUtils;

import java.util.ArrayList;
import java.util.List;

public class ReplenishSkuDetailActivity extends BaseActivity implements View.OnClickListener {

    private ListView listview_distributionDetails;
    private ListView listview_groundingSuggest;
    private TextView tv_skuCode;
    private TextView tv_expectNumber;
    private TextView tv_actualNumber;
    private List<PutawaysBean> putaways;
    private List<AllotsBean> allots;
    private ItemsBean itemsBean;
    private ReplenishSkuAssignmentDetailAdapter replenishSkuAssignmentDetailAdapter;
    private ReplenishSkuGroundingDetailAdapter replenishSkuGroundingDetailAdapter;

    @Override
    protected void onActivityCreate(Bundle savedInstanceState) {
        setContentView(R.layout.activity_replenish_sku_detail);
    }

    @Override
    protected void initView() {
        findViewById(R.id.iv_back).setOnClickListener(this);

        tv_skuCode = findViewById(R.id.tv_skuCode);
        tv_expectNumber = findViewById(R.id.tv_expectNumber);
        tv_actualNumber = findViewById(R.id.tv_actualNumber);
        listview_distributionDetails = findViewById(R.id.listview_distributionDetails);
        replenishSkuAssignmentDetailAdapter = new ReplenishSkuAssignmentDetailAdapter(this);
        listview_distributionDetails.setAdapter(replenishSkuAssignmentDetailAdapter);

        listview_groundingSuggest = findViewById(R.id.listview_groundingSuggest);
        replenishSkuGroundingDetailAdapter = new ReplenishSkuGroundingDetailAdapter(this);
        listview_groundingSuggest.setAdapter(replenishSkuGroundingDetailAdapter);

        itemsBean = (ItemsBean) getIntent().getSerializableExtra("itemsBean");
        putaways = (List<PutawaysBean>) getIntent().getSerializableExtra("putaways");
        allots = (List<AllotsBean>) getIntent().getSerializableExtra("allots");
    }

    @Override
    protected void initData() {
        tv_skuCode.setText("SKU编码：" + itemsBean.getItemskuCode());
        tv_expectNumber.setText(itemsBean.getWantQty() + "");
        tv_actualNumber.setText(itemsBean.getRealQty() + "");

        if (putaways == null) putaways = new ArrayList<>();
        replenishSkuGroundingDetailAdapter.setData(putaways);

        if (allots == null) allots = new ArrayList<>();
        replenishSkuAssignmentDetailAdapter.setData(allots);
    }

    @Override
    public void onClick(View v) {
        if (FastClickUtil.isFastClick()) {
            return;
        }
        switch (v.getId()) {
            case R.id.iv_back:
                finish();
                break;
        }
    }

    @Override
    protected void onNetworkAvailable() {

    }

    @Override
    protected void onNetworkError() {
        ToastUtils.showLongOnDeepBg(ReplenishSkuDetailActivity.this, "网络连接失败");
    }
}
